package com.back.campus_back.service.impl;

import com.back.campus_back.domain.Carousel;
import com.back.campus_back.domain.Orders;
import com.back.campus_back.domain.OrdersVo;
import com.back.campus_back.domain.ReportGoods;
import com.back.campus_back.mapper.ReportGoodsMapper;
import com.back.campus_back.service.ReportGoodsService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ${author}
 * @since 2021-04-17
 */
@Service
public class ReportGoodsServiceImpl extends ServiceImpl<ReportGoodsMapper, ReportGoods> implements ReportGoodsService {

    @Autowired
    private ReportGoodsMapper reportGoodsMapper;

    //根据商品id获取评论
    @Override
    public List getReport(Integer goods_id) {

        List list = reportGoodsMapper.getReport(goods_id);
        List list1 = new ArrayList();
        for(Object newList:list){
            list1.add(newList);
        }
        return list1;
    }

    //发表评论
    @Override
    public String addReport(ReportGoods reportGoods) {
        int insert = reportGoodsMapper.insert(reportGoods);
        if(insert == 1){
            return "success";
        }else{
            return "error";
        }

    }

    //查看所有评论
    @Override
    public List findAllReport() {
        List allReport = reportGoodsMapper.findAllReport();
        return allReport;
    }





}
